using System;

using IGlobalist.Chat.Engine.Common;

namespace IGlobalist.Chat.Engine
{
    [Serializable]
	public class Message 
	{
		#region Members
        private string _Sender;        
        private string _Msg;        
        private MsgType _Type;        
        private string _Receiver;

		#endregion 

        #region Properties

        public string Sender
        {
            get { return _Sender; }
            set { _Sender = value; }
        }
        public string Msg
        {
            get { return _Msg; }
            set { _Msg = value; }
        }

        public MsgType Type
        {
            get { return _Type; }
            set { _Type = value; }
        }
       
        public string Receiver
        {
            get { return _Receiver; }
            set { _Receiver = value; }
        }

        #endregion


        #region Constructors
        public Message(string sender, string msg, MsgType type) 
		{
			_Sender = sender;
			_Msg = msg;
			_Type = type;
		}

        public Message(string sender,string receiver, string msg, MsgType type)
        {
            _Sender = sender;
            _Receiver = receiver;
            _Msg = msg;
            _Type = type;
        }

		public Message(string _user, MsgType _type) : this(_user, "", _type) { }
		public Message(MsgType _type) : this("", "", _type) { }
		#endregion 

		#region Methods
		public override string ToString()
		{
			switch(this.Type)
			{
				case MsgType.Msg:
					return string.Format("<b>{0}:</b> {1}",this.Sender,this.Msg);
				case MsgType.Join :
					return string.Format("<font style='color:blue'><b>{0}:</b> has joined the room</font>",this.Sender );
				case MsgType.Left :
                    return string.Format("<font style='color:red'><b>{0}:</b> has left the room</font>", this.Sender); 
			}
			return "";
		}
		#endregion 

	}

	

	
}
